--- import Layout from "@layouts/layout.astro"; import Nav from "@components/Nav.astro"; import KlaskBoard from "@components/KlaskBoard.astro"; import VirtualGame from "@components/VirtualGame.astro"; import { init, getGame, getUser } from "@utils/db"; import { getUserFromRequest } from "@utils/auth"; await init(); const { id } = Astro.params; if (!id) return Astro.redirect("/"); const game = await getGame(id); if (!game) { return new Response("Game not found", { status: 404 }); } const currentUserName = getUserFromRequest(Astro.request); const currentUser = currentUserName ? await getUser(currentUserName) : null; const isPlayer1 = currentUserName === game.player1; const isPlayer2 = currentUserName === game.player2; const isParticipant = isPlayer1 || isPlayer2; const canJoin = !isParticipant && game.status === "waiting" && currentUserName && currentUserName !== game.player1; const origin = new URL(Astro.request.url).origin; const gameUrl = `${origin}/game/${id}`; const isVirtual = game.mode === "virtual"; ---